import base from "./base";
import config from "../config/index";

class api extends base{
	constructor() {
		super();
	}

	checkToken = () => uniCloud.callFunction({
		name: 'user-center',
		data: {
			action: 'checkToken'
		}
	})

	logout = () => uniCloud.callFunction({
		name: 'user-center',
		data: {
			action: 'logout'
		},
		success(e) {
			uni.showModal({
				showCancel: false,
				content: JSON.stringify(e.result)
			})
			uni.removeStorageSync('uniIdToken')
			uni.removeStorageSync('uni_id_token_expired')
		},
		fail(e) {
			console.error(e)
			uni.showModal({
				showCancel: false,
				content: '登出失败，请稍后再试'
			})
		}
	})
}

export default new api()
